home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11056 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  87 lines

  1. Path: cls.net!news
  2. From: damian@sup.de (Damian Gruszka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help ! Please help me solve the problem
  5. Date: 21 Mar 1996 18:52:07 GMT
  6. Organization: sup.de
  7. Message-ID: <4is8gn$odj@freeside.cls.de>
  8. References: <4iqqb2$bkf@ctylnk.cityu.edu.hk>
  9. NNTP-Posting-Host: kldos3.sup.de
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.11
  12.  
  13. In article <4iqqb2$bkf@ctylnk.cityu.edu.hk>, 00842506@cpccux0.cityu.edu.hk 
  14. says...
  15. >
  16. >  I want to write a disk cache program and so must place my new interrupt
  17. >  point into interrupt vector 13 which points to my new function. 
  18. >  Please take a look at my simple test program please:
  19. >
  20. >  unsign long old_int_pointer;
  21. >
  22. >  new_int_function()
  23. >     {
  24. >     
  25. >       
  26. >      /* just jump to old_int_pointer  which read from disk 
  27. >         because it is a test program so nothing others is done */
  28. >
  29. >     }
  30. >
  31. >  main()
  32. >     {
  33. >      /* save old int13 pointer into old_int_pointer
  34. >         using int21h ax=3513 */
  35. >      
  36. >      /* put address of new_int_function() into vector 13 area
  37. >         using int21h ax=2513 */
  38. >
  39. >      /* TSR function goes here */
  40. >
  41. >     }
  42. >
  43. > Save and put new interrupt address and TSR is OK.
  44. >
  45. > However when disk reading is involved, it hangs.
  46. >
  47. > My problem is : 
  48. >      1) what code should write so it can jump to my 
  49. >         old_int_pointer. I have though for a long time!! :-(
  50. >      2) I am afraid that when control is passed to new_int_function,
  51. >         it can not retrieve values such as old_int_pointer because
  52. >         the segment register may not match as that in my program.
  53. >
  54. > Please send me a mail if you have any idea.
  55. > Thanks a lot !! :-)
  56. >
  57. > N.Cheung
  58. > 00842506@cpccux0.cityu.edu.hk
  59. >
  60. >
  61. Try something like this (using Borland's BCC or Watcom C)
  62.  
  63.  
  64. #include <dos.h>
  65. /* some others includes */
  66.  
  67. void interrupt  (*old_int_ptr)(void);
  68.  
  69. void interrupt __loadds new_int_func(void){
  70. old_int_ptr();
  71. }
  72.  
  73. int main(){
  74.  
  75. old_int_ptr = getvect(0x13);
  76. setvect(0x13);
  77. while(TRUE);/* ;-)) */
  78. }
  79.  
  80. Alternatively you can declare old_int_ptr as __cs variable.
  81.  
  82.  
  83. D.Gruszka
  84. damian@sup.de
  85.  
  86.